home *** CD-ROM | disk | FTP | other *** search
- // comma.cpp: Extract comma-delimited tokens
- #include <iostream.h>
- #include <strstream.h>
- #include <stddef.h>
-
- main()
- {
- const size_t BUFSIZ = 128;
- char s[BUFSIZ];
-
- while (cin.getline(s,BUFSIZ))
- {
- char name[16], addr[26], city[16], state[5], zip[6];
- istrstream sstr(s);
-
- sstr.getline(name,sizeof name,',');
- sstr.getline(addr,sizeof addr,',');
- sstr.getline(city,sizeof city,',');
- sstr.getline(state,sizeof state,',');
- sstr.getline(zip,sizeof zip);
- cout << name << '|'
- << addr << '|'
- << city << '|'
- << state << '|'
- << zip << endl;
- }
-
- return 0;
- }
-
-